package com.creditcmsplt.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.creditcmsplt.entity.CreditCsvConvert;

/**
 * 数据库操作DAO：creditlog表
 * 
 * @author Administrator
 *
 */
public interface CreditCsvConvertMapper {

	//#{auoth_id,jdbcType=INTEGER}
	@Insert("INSERT INTO t_credit_csvconvert(auoth_id,vendor_key,identify,credit_queryid,pdfname,applytype,converttype,convertnum,downloadcode,status,created_at,updated_at) VALUES "
			+ "(#{auoth_id,jdbcType=INTEGER},#{vendor_key,jdbcType=VARCHAR},#{identify,jdbcType=VARCHAR},#{credit_queryid,jdbcType=VARCHAR},#{pdfname,jdbcType=VARCHAR},#{applytype,jdbcType=SMALLINT},#{converttype,jdbcType=VARCHAR},#{convertnum,jdbcType=SMALLINT},#{downloadcode,jdbcType=VARCHAR},0,NOW(),NOW())")
	@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
	public Integer insert(CreditCsvConvert creditCsvConvert);

	@Update("UPDATE t_credit_csvconvert set status=#{status},updated_at=NOW() where pdfname=#{pdfname} or  credit_queryid=#{pdfname}")
	public void update(@Param("pdfname") String pdfname,@Param("status") Integer status);
	
	@Select("select id,auoth_id,vendor_key,identify,credit_queryid,pdfname,applytype,converttype,convertnum,downloadcode,status,created_at,updated_at from t_credit_csvconvert where credit_queryid=#{credit_queryid} LIMIT 1")
	public CreditCsvConvert getObject(@Param("credit_queryid") String credit_queryid);

}

